package com.app.service.impl;

import com.app.mapper.PersonResumeMapper;
import com.app.mapper.TestsPersonMapper;
import com.app.model.PersonResumeModel;
import com.app.model.TestsPersonModel;
import com.app.service.PersonResumeService;
import com.app.service.TestsPersonService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Primary
public class TestsPersonServiceImpl implements TestsPersonService {
    @Autowired
    TestsPersonMapper testsPersonMapper;


    @Override
    public TestsPersonModel getPersonByTestId(Integer testsId) {
        QueryWrapper<TestsPersonModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","tests_id","person_id","start_time","end_time","content").eq("tests_id",testsId);
        TestsPersonModel testsPersonModel = testsPersonMapper.selectOne(queryWrapper);
        return testsPersonModel;
    }

    @Override
    public List<TestsPersonModel> getTestsPersonList(int testsId) {
        QueryWrapper<TestsPersonModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","tests_id","person_id","start_time","end_time","content").eq("tests_id",testsId).orderByAsc("start_time");
        List<TestsPersonModel> testsModelList = testsPersonMapper.selectList(queryWrapper);
        return testsModelList;
    }

    @Override
    public void update(TestsPersonModel model) {
        testsPersonMapper.updateById(model);
    }

    @Override
    public void insert(TestsPersonModel model) {
        testsPersonMapper.insert(model);
    }

    @Override
    public void delete(int id) {
        testsPersonMapper.deleteById(id);
    }
}
